﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace SMQCS2
{
    public partial class Form1 : Form
    {

        private StringBuilder barcode = new StringBuilder();
        private int s = 0;
        private DateTime _firstScanTime;


        public Form1()
        {
            InitializeComponent();
            this.KeyPreview = true;
            this.KeyPress += Form1_KeyPress;


        }

        private void Form1_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)Keys.Enter)
            {
                s++;
                textBox2.Text= s.ToString();
             
                //      textBox3.Text= _firstScanTime.ToString();

                double elapsed = (DateTime.Now- _firstScanTime).TotalSeconds;
                double avg = elapsed/s;

                    textBox3.Text=avg.ToString();
            }
           
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (s == 0)
            {
                _firstScanTime = DateTime.Now;
                textBox3.Text = "0.00";
                return;
            }

        }
    }
}
